{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=181
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i, j, n, cur, tt, k : longint;
	a : array[0..110, 0..110] of boolean;
	used : array[0..110] of boolean;
	ok : boolean;
 
procedure dfs(v : longint);
 
var
	i : longint;
 
begin
	used[v] := true;
	for i := 1 to n do
		if a[v][i] and (not used[i]) then dfs(i);
end;
 
begin
	reset(input,'input.txt');
	rewrite(output,'output.txt');
	fillchar(a, sizeof(a), 0);
	read(n);
	cur := 0;
	for i := 1 to n do
		for j := 1 to n do begin
			read(k);
			if k = 1 then begin
				a[i][j] := true;
				inc(cur);
			end;
		end;
	fillchar(used, sizeof(used), 0);
	tt := 0;
	for i := 1 to n do
		if not used[i] then begin
			dfs(i);
			inc(tt);
		end;
	ok := (cur = (n - 1) shl 1) and (tt = 1);
	if ok then write('YES') else write('NO');
end.